package cn.ywsj.ywsjmidtier.controller;

import cn.ywsj.ywsjmidtier.entity.InviteCode;
import cn.ywsj.ywsjmidtier.entity.VO.CreditAccountQueryVo;
import cn.ywsj.ywsjmidtier.entity.VO.InviteBuyerQueryVo;
import cn.ywsj.ywsjmidtier.entity.VO.InviteCodeVo;
import cn.ywsj.ywsjmidtier.service.WechatInviteBuyerFeign;
import cn.ywsj.ywsjmidtier.utils.JsonObjectUtil;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "我的供应商")
@RestController
@RequestMapping("/wechat/member/invitebuyermgr")
public class WechatInviteBuyerController {
    @Autowired
    private WechatInviteBuyerFeign wechatInviteBuyerFeign;

    /**
     * 邀请码
     * @param inviteCodeVo
     * @return
     */
    @ApiOperation("邀请码")
    @PostMapping("/setinvitecode")
    public String setinvitecode(InviteCodeVo inviteCodeVo){
        /*MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
        map.add("inviteCode",inviteCodeVo.getInviteCode());*/
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(inviteCodeVo);
        return wechatInviteBuyerFeign.setinvitecode(jsonObject);
    }

    /**
     * 我的供应商_详情
     * @param creditAccountQueryVo
     * @return
     */
    @ApiOperation("我的供应商_详情")
    @PostMapping("/getcreditaccountbycustid")
    public String getCreditAccountByCustId(CreditAccountQueryVo creditAccountQueryVo) {
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(creditAccountQueryVo);
        return wechatInviteBuyerFeign.getCreditAccountByCustId(jsonObject);
    }

    /**
     * 我的供应商_邀请管理
     * @param state
     * @param pageSize
     * @return
     */
    @ApiOperation("我的供应商_邀请管理")
    @PostMapping("/ajaxinvitelist")
    public String ajaxInviteList(InviteBuyerQueryVo inviteBuyerQueryVo, Integer state, Integer pageSize){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(inviteBuyerQueryVo);
        return wechatInviteBuyerFeign.ajaxInviteList(jsonObject,state,pageSize);
    }
    @PostMapping("/getinvitecodelist")
    public String getinvitecodelist(InviteCode inviteCode){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(inviteCode);
        return wechatInviteBuyerFeign.getinvitecodelist(jsonObject);
    }
}

